#include "StdAfx.h"
#include "ModelSceneEditorObject.h"


CModelSceneEditorObject::CModelSceneEditorObject(void):content("")
{
	m_nType = SOT_MODEL ;
}


CModelSceneEditorObject::~CModelSceneEditorObject(void)
{

}

std::string& CModelSceneEditorObject::GetContent()
{
	if ( content.size() <= 0 )
	{
		Ogre::DataStreamPtr data_ptr = Ogre::ResourceGroupManager::getSingleton().openResource( modelname,groupname ) ;
		Ogre::MemoryDataStreamPtr mem_ptr = Ogre::MemoryDataStreamPtr( new Ogre::MemoryDataStream( data_ptr ) ) ;
		//mem_ptr->getPtr() ;
		int nSize = mem_ptr->size() ;
		char* pBuf = new char[nSize + 1] ;
		ZeroMemory( pBuf,nSize + 1 ) ;
		memcpy( pBuf,mem_ptr->getPtr(),nSize ) ;
		content = pBuf ;
		delete[] pBuf ;
		pBuf = NULL ;

		mem_ptr->close() ;
		data_ptr->close() ;
	}
	return content ;
}
